﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

// Global definitions
// accessed from the instance
public class GameData : MonoBehaviour {
	public static GameData instance;
	
	public TextAsset BuildingsAsset;
	public TextAsset UnitsAsset;
	public TextAsset SkillsAsset;
	public TextAsset PowerupsAsset;
	
	private XmlDataBase buildingsData;
	private XmlDataBase unitsData;
	private XmlDataBase skillsData;
	private XmlDataBase powerupsData;
	
	public XmlDataBase BuildingsData { get { return buildingsData; } }
	public XmlDataBase UnitsData { get { return unitsData; } }
	//private bool loaded = false;
	
	void Awake() {
		if (instance == null) {
			DontDestroyOnLoad(this);
			instance = this;
			Load();
		}
	}
	
	void Start() {
	}
	
	void Load() {
		buildingsData = new XmlDataBase();
		buildingsData.asset = BuildingsAsset;
		buildingsData.Load();
		
		unitsData = new XmlDataBase();
		unitsData.asset = UnitsAsset;
		unitsData.Load();
		
		skillsData = new XmlDataBase();
		skillsData.asset = SkillsAsset;
		skillsData.Load();
		
		powerupsData = new XmlDataBase();
		powerupsData.asset = PowerupsAsset;
		powerupsData.Load();
		
		//...
		
		//loaded = true;
	}
}
